<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    input {
      outline: 0;
    }
  </style>
</head>

<body>
  <div class="number">账号：<input type="text"></div>
  <div class="password">密码：<input type="password">
    <button>点我显示与隐藏</button>
  </div>
  <script>
    const btn = document.querySelector('button')
    const password = document.querySelector('.password input')
    btn.addEventListener('click', function() {
      if (password.type === 'password') {
        password.type = 'text'
      } else {
        password.type = 'password'
      }
    })
  </script>
</body>

</html>